home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / MW MPW Binaries 1.1.1a2 / mwcPPC / MWCIncludes / math.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-25  |  8.8 KB  |  367 lines  |  [TEXT/MMCC]

  1. /* math.h standard header */
  2. #ifdef __MWERKS__ /* __MWERKS__ */
  3.  
  4. #ifdef    powerc
  5. #ifndef __MATH__
  6. #define    __MATH__
  7.  
  8. #if __MWERKS__
  9. #pragma options align=mac68k
  10. #endif
  11.  
  12. /*    We need the pascal keyword for compiling fp.h */
  13. #pragma only_std_keywords off
  14. #include    <fp.h>
  15.  
  16. typedef union {
  17.     unsigned short _W[5];
  18.     float _F;
  19.     double _D;
  20.     long double _L;
  21.     } _Dconst;
  22.  
  23. float cosf(float);
  24. float sinf(float);
  25. float powf(float, float);
  26. float logf(float);
  27. float atan2f(float, float);
  28. float sqrtf(float);
  29. float ldexpf(float, int);
  30. float fabsf(float);
  31. float _FCosh(float, float);
  32. float _FSinh(float, float);
  33. float _FLog(float, int);
  34. float _FSin(float, unsigned int);
  35.  
  36. #if __MWERKS__
  37. #pragma options align=reset
  38. #endif
  39.  
  40. #endif /* __MATH__ */
  41. #endif /* powerc */
  42.  
  43. #ifndef __MATH__
  44. #define __MATH__
  45.  
  46. #if __MWERKS__
  47. #pragma options align=mac68k
  48. #endif
  49.  
  50. /*    We need the pascal keyword for compiling Types.h */
  51. #pragma only_std_keywords off
  52. #include <Types.h>
  53.  
  54. #define _PI            (*(long double *)__pi)
  55. #define HUGE_VAL    (*(long double *)__minf__)
  56.  
  57. extern short    __minf__[],__pi[];
  58.  
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62.  
  63. //    Conversion routines for between 10byte and 12byte long doubles ...
  64. extern asm void __x96tox80(extended96 *,extended80 *);
  65. extern asm void __x80tox96(extended80 *,extended96 *);
  66.  
  67.  
  68. #if __MC68881__
  69.  
  70. long double _sin(long double:__FP0):__FP0 = { 0xF200,0x000E };
  71. long double _cos(long double:__FP0):__FP0 = { 0xF200,0x001D };
  72. long double _tan(long double:__FP0):__FP0 = { 0xF200,0x000F };
  73. long double _asin(long double:__FP0):__FP0 = { 0xF200,0x000C };
  74. long double _acos(long double:__FP0):__FP0 = { 0xF200,0x001C };
  75. long double _atan(long double:__FP0):__FP0 = { 0xF200,0x000A };
  76. long double _sinh(long double:__FP0):__FP0 = { 0xF200,0x0002 };
  77. long double _cosh(long double:__FP0):__FP0 = { 0xF200,0x0019 };
  78. long double _tanh(long double:__FP0):__FP0 = { 0xF200,0x0009 };
  79. long double _exp(long double:__FP0):__FP0 = { 0xF200,0x0010 };
  80. long double _log(long double:__FP0):__FP0 = { 0xF200,0x0014 };
  81. long double _log10(long double:__FP0):__FP0 = { 0xF200,0x0015 };
  82. long double _sqrt(long double:__FP0):__FP0 = { 0xF200,0x0004 };
  83. long double _fabs(long double:__FP0):__FP0 = { 0xF200,0x0018 };
  84. long double _fmod(long double:__FP0,long double:__FP1):__FP0 = { 0xF200,0x0421 };
  85. long double _ldexp(long double:__FP0,int:__D0):__FP0 = { 0xF200,0x4026 };
  86.  
  87. #ifndef    __HYBRIDMATH__
  88.  
  89. #define sin(x)        _sin(x)
  90. #define cos(x)        _cos(x)
  91. #define tan(x)        _tan(x)
  92. #define asin(x)        _asin(x)
  93. #define acos(x)        _acos(x)
  94. #define atan(x)        _atan(x)
  95. #define sinh(x)        _sinh(x)
  96. #define cosh(x)        _cosh(x)
  97. #define tanh(x)        _tanh(x)
  98. #define exp(x)        _exp(x)
  99. #define sqrt(x)        _sqrt(x)
  100. #define fabs(x)        _fabs(x)
  101. #define fmod(x,y)    _fmod((x),(y))
  102. #define ldexp(x,n)    _ldexp((x),(n))
  103.  
  104. #ifdef __FASTMATH__
  105. #define log(x)        _log(x)
  106. #define log10(x)    _log10(x)
  107. #endif /* __FASTMATH__ */
  108.  
  109. #endif /* __HYBRIDMATH */
  110.  
  111. #endif /* __MC68881__ */
  112.  
  113. double (sin)(double);
  114. double (cos)(double);
  115. double (tan)(double);
  116. double (asin)(double);
  117. double (acos)(double);
  118. double (atan)(double);
  119. double (atan2)(double,double);
  120. double (sinh)(double);
  121. double (cosh)(double);
  122. double (tanh)(double);
  123. double (exp)(double);
  124. double (log)(double);
  125. double (log10)(double);
  126. double (pow)(double,double);
  127. double (sqrt)(double);
  128. double (ceil)(double);
  129. double (floor)(double);
  130. double (fabs)(double);
  131. double (ldexp)(double,int);
  132. double (frexp)(double,int *);
  133. double (modf)(double,double *);
  134. double (fmod)(double,double);
  135.  
  136.  
  137.         /* float declarations */
  138. float acosf(float);
  139. float asinf(float);
  140. float atanf(float);
  141. float atan2f(float, float);
  142. float cosf(float);
  143. float sinf(float);
  144. float ceilf(float);
  145. float expf(float);
  146. float fabsf(float);
  147. float floorf(float);
  148. float fmodf(float, float);
  149. float frexpf(float, int *);
  150. float ldexpf(float, int);
  151. float modff(float, float *);
  152. float powf(float, float);
  153. float sqrtf(float);
  154. float tanf(float);
  155. float tanhf(float);
  156. float _FCosh(float, float);
  157. float _FLog(float, int);
  158. float _FSin(float, unsigned int);
  159. float _FSinh(float, float);
  160. float coshf(float);
  161. float logf(float);
  162. float log10f(float);
  163. float sinhf(float);
  164.  
  165. /*
  166. #define cosf(x)        _FSin(x, 1)
  167. #define coshf(x)    _FCosh(x, 1)
  168. #define logf(x)        _FLog(x, 0)
  169. #define log10f(x)    _FLog(x, 1)
  170. #define sinf(x)        _FSin(x, 0)
  171. #define sinhf(x)    _FSinh(x, 1)
  172. */
  173.  
  174. typedef union {
  175.     unsigned short _W[5];
  176.     float _F;
  177.     double _D;
  178.     long double _L;
  179.     } _Dconst;
  180.  
  181.  
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185.  
  186. #if __MWERKS__
  187. #pragma options align=reset
  188. #endif
  189.  
  190. #endif /* __MATH__ */
  191.  
  192. #else /* !__MWERKS__ */
  193.  
  194. #ifndef _MATH
  195. #define _MATH
  196. #include <yvals.h>
  197.         /* macros */
  198. #define HUGE_VAL    _Hugeval._D
  199.         /* type definitions */
  200. #if defined(__CENTERLINE__)
  201. typedef struct {
  202. #else
  203. typedef union {
  204. #endif
  205.     unsigned short _W[5];
  206.     float _F;
  207.     double _D;
  208.     long double _L;
  209.     } _Dconst;
  210. _C_LIB_DECL
  211.         /* double declarations */
  212. double acos(double);
  213. double asin(double);
  214. double atan(double);
  215. double atan2(double, double);
  216. double ceil(double);
  217. double exp(double);
  218. double fabs(double);
  219. double floor(double);
  220. double fmod(double, double);
  221. double frexp(double, int *);
  222. double ldexp(double, int);
  223. double modf(double, double *);
  224. double pow(double, double);
  225. double sqrt(double);
  226. double tan(double);
  227. double tanh(double);
  228. double _Cosh(double, double);
  229. double _Log(double, int);
  230. double _Sin(double, unsigned int);
  231. double _Sinh(double, double);
  232. extern const _Dconst _Hugeval;
  233.         /* float declarations */
  234. float acosf(float);
  235. float asinf(float);
  236. float atanf(float);
  237. float atan2f(float, float);
  238. float ceilf(float);
  239. float expf(float);
  240. float fabsf(float);
  241. float floorf(float);
  242. float fmodf(float, float);
  243. float frexpf(float, int *);
  244. float ldexpf(float, int);
  245. float modff(float, float *);
  246. float powf(float, float);
  247. float sqrtf(float);
  248. float tanf(float);
  249. float tanhf(float);
  250. float _FCosh(float, float);
  251. float _FLog(float, int);
  252. float _FSin(float, unsigned int);
  253. float _FSinh(float, float);
  254.         /* long double declarations */
  255. long double acosl(long double);
  256. long double asinl(long double);
  257. long double atanl(long double);
  258. long double atan2l(long double, long double);
  259. long double ceill(long double);
  260. long double expl(long double);
  261. long double fabsl(long double);
  262. long double floorl(long double);
  263. long double fmodl(long double, long double);
  264. long double frexpl(long double, int *);
  265. long double ldexpl(long double, int);
  266. long double modfl(long double, long double *);
  267. long double powl(long double, long double);
  268. long double sqrtl(long double);
  269. long double tanl(long double);
  270. long double tanhl(long double);
  271. long double _LCosh(long double, long double);
  272. long double _LLog(long double, int);
  273. long double _LSin(long double, unsigned int);
  274. long double _LSinh(long double, long double);
  275. _END_C_LIB_DECL
  276. #ifdef __cplusplus
  277.         /* double inlines, for C++ */
  278. inline double cos(double _X)
  279.     {return (_Sin(_X, 1)); }
  280. inline double cosh(double _X)
  281.     {return (_Cosh(_X, 1)); }
  282. inline double log(double _X)
  283.     {return (_Log(_X, 0)); }
  284. inline double log10(double _X)
  285.     {return (_Log(_X, 1)); }
  286. inline double sin(double _X)
  287.     {return (_Sin(_X, 0)); }
  288. inline double sinh(double _X)
  289.     {return (_Sinh(_X, 1)); }
  290.         /* float inlines, for C++ */
  291. inline float cosf(float _X)
  292.     {return (_FSin(_X, 1)); }
  293. inline float coshf(float _X)
  294.     {return (_FCosh(_X, 1)); }
  295. inline float logf(float _X)
  296.     {return (_FLog(_X, 0)); }
  297. inline float log10f(float _X)
  298.     {return (_FLog(_X, 1)); }
  299. inline float sinf(float _X)
  300.     {return (_FSin(_X, 0)); }
  301. inline float sinhf(float _X)
  302.     {return (_FSinh(_X, 1)); }
  303.         /* long double inlines, for C++ */
  304. inline long double cosl(long double _X)
  305.     {return (_LSin(_X, 1)); }
  306. inline long double coshl(long double _X)
  307.     {return (_LCosh(_X, 1)); }
  308. inline long double logl(long double _X)
  309.     {return (_LLog(_X, 0)); }
  310. inline long double log10l(long double _X)
  311.     {return (_LLog(_X, 1)); }
  312. inline long double sinl(long double _X)
  313.     {return (_LSin(_X, 0)); }
  314. inline long double sinhl(long double _X)
  315.     {return (_LSinh(_X, 1)); }
  316. #else
  317.         /* double macro overrides, for C */
  318. double cos(double);
  319. double cosh(double);
  320. double log(double);
  321. double log10(double);
  322. double sin(double);
  323. double sinh(double);
  324. #define cos(x)        _Sin(x, 1)
  325. #define cosh(x)        _Cosh(x, 1)
  326. #define log(x)        _Log(x, 0)
  327. #define log10(x)    _Log(x, 1)
  328. #define sin(x)        _Sin(x, 0)
  329. #define sinh(x)        _Sinh(x, 1)
  330.         /* float macro overrides, for C */
  331. float cosf(float);
  332. float coshf(float);
  333. float logf(float);
  334. float log10f(float);
  335. float sinf(float);
  336. float sinhf(float);
  337. #define cosf(x)        _FSin(x, 1)
  338. #define coshf(x)    _FCosh(x, 1)
  339. #define logf(x)        _FLog(x, 0)
  340. #define log10f(x)    _FLog(x, 1)
  341. #define sinf(x)        _FSin(x, 0)
  342. #define sinhf(x)    _FSinh(x, 1)
  343.         /* long double macro overrides, for C */
  344. long double cosl(long double);
  345. long double coshl(long double);
  346. long double logl(long double);
  347. long double log10l(long double);
  348. long double sinl(long double);
  349. long double sinhl(long double);
  350. #define cosl(x)        _LSin(x, 1)
  351. #define coshl(x)    _LCosh(x, 1)
  352. #define logl(x)        _LLog(x, 0)
  353. #define log10l(x)    _LLog(x, 1)
  354. #define sinl(x)        _LSin(x, 0)
  355. #define sinhl(x)    _LSinh(x, 1)
  356. #endif
  357.  
  358. #endif
  359.  
  360. #endif /* __MWERKS__ */
  361.  
  362. /*
  363.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  364.  * Consult your license regarding permissions and restrictions.
  365.  */
  366.  
  367.